package com.dd.stack.mybatisplus.pojo.req;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dd.stack.common.util.verification.DataVerificationUtil;
import com.dd.stack.mybatisplus.pojo.DO.JsonValueDO;
import com.dd.stack.mybatisplus.pojo.enumeration.DOTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/1/8 23:04
 * @Description 添加DataObject请求类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("添加DataObject请求类")
public class DataObjectAddReq {
    @ApiModelProperty("整型包装类")
    private Integer intValue;
    @ApiModelProperty("长整型包装类")
    private Long longValue;
    @ApiModelProperty("双精度浮点型包装类")
    private Double doubleValue;
    @ApiModelProperty("字符串类型")
    private String stringValue;
    @ApiModelProperty("本地日期时间类型")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "local_datetime_value")
    private LocalDateTime localDateTimeValue;
    @ApiModelProperty("json字符串类型数据")
    private JsonValueDO jsonValue;
    @ApiModelProperty("用户类型【DOTypeEnum枚举】 枚举信息请从枚举信息接口获取 前端传code属性")
    private String userType;

    // 数据验证
    public Boolean existEmptyData() {
        return DataVerificationUtil.isEmpty(intValue)
                || DataVerificationUtil.isEmpty(longValue)
                || DataVerificationUtil.isEmpty(doubleValue)
                || DataVerificationUtil.isEmpty(stringValue)
                || DataVerificationUtil.isEmpty(localDateTimeValue)
                || DataVerificationUtil.isEmpty(jsonValue);
    }
}
